package com.ludomancy.archeologyrpg.entities;

import java.awt.Graphics;
import java.awt.Point;
import java.util.Iterator;
import java.util.Vector;
import com.ludomancy.archeologyrpg.Entity;

public class AlienBase extends Entity
{
	public Vector generators = new Vector();

	public AlienBase(Point p)
	{
		super(p);
	}
	
	public void plugGenerator(Generator generator)
	{
		generators.add(generator);
	}

	public void paint(Graphics g, int x, int y)
	{
		if(isPowered())
		{
			paintDefaultIcon(g, ALIEN_BASE_ON, x, y);
		}
		else
		{
			paintDefaultIcon(g, ALIEN_BASE_OFF, x, y);
		}
	}
	
	private boolean isPowered()
	{
		int power = 0;
		for (Iterator iter = generators.iterator(); iter.hasNext();)
		{
			Generator gen = (Generator) iter.next();
			if(gen.isPowered())
			{
				power++;
			}
		}
		return power == generators.size();
	}
	
	public void update(boolean running, boolean activated)
	{
		if(activated)
		{
			if(isPowered())
			{
				System.out.println("activated alien base");
			}
			else
			{
				System.out.println("shut down alien base");
			}
			
		}
	}

	public void paintInfo(Graphics g)
	{
	}

	public String getActionVerb()
	{
		return "Explore";
	}
}
